package com.example.xunua_zhinengjiaotong.adapter;

import android.content.Context;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

public class MyViewpagerAdapter extends FragmentPagerAdapter {
    Context context;
    List<Fragment> fragmentList;

    public MyViewpagerAdapter(FragmentManager fm, Context context, List<Fragment> fragmentList) {
        super(fm);
        this.context = context;
        this.fragmentList = fragmentList;
    }

    /**
     * 获取当前页面
     * @param position
     * @return
     */
    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    /**
     * 获取页面个数
     * @return
     */
    @Override
    public int getCount() {
        return fragmentList!=null?fragmentList.size():0;
    }
}
